package touhou.game;

import java.awt.geom.Point2D;

import touhou.base.Movable;
import touhou.base.SpeedVector;
import touhou.base.SpeedVectorDoubleImpl;

public abstract class GameMovable extends GameEntity implements Movable {
	
	public GameMovable() {
		super(new Point2D.Double(0,0));
	}

	GameMovableDriver moveDriver = new GameMovableDriverDefaultImpl();

	SpeedVector speedVector = SpeedVectorDoubleImpl.createNullVector();

	public void setSpeedVector(SpeedVector speedVector) {
		this.speedVector = (SpeedVector) speedVector.clone();
	}

	public SpeedVector getSpeedVector() {
		return (SpeedVector) speedVector.clone();
	}

	public void setDriver(GameMovableDriver driver) {
		moveDriver = driver;
	}

	public GameMovableDriver getDriver() {
		return moveDriver;
	}

	public void oneStepMove() {
		SpeedVector m = moveDriver.getSpeedVector(this);
		speedVector.setDirection(m.getDirection());
		speedVector.setSpeed(m.getSpeed());
		translate(speedVector.getDirection().getX()
				* speedVector.getSpeed(), speedVector.getDirection()
				.getY() * speedVector.getSpeed());
		oneStepMoveAddedBehavior();
	}
	
	@Deprecated
	public void setMoveSpeed(int projectileSpeed) {
		speedVector.setSpeed(projectileSpeed);
	}

	public abstract void oneStepMoveAddedBehavior();
}
